package com.heaven1949.tmall.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.heaven1949.tmall.common.core.dto.ApiResult;
import com.heaven1949.tmall.common.web.controller.BaseController;
import com.heaven1949.tmall.order.dto.OrderDTO;
import com.heaven1949.tmall.order.dto.OrderPageQueryDTO;
import com.heaven1949.tmall.order.entity.OrderEntity;
import com.heaven1949.tmall.order.service.IOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单信息controller
 *
 * @author zhangjian
 * @date 2023-03-08 16:28:13
 */
@RestController
@RequestMapping("/api/order")
@RequiredArgsConstructor
public class OrderController extends BaseController {

    private final IOrderService orderService;

    /**
     * 分页查询
     *
     * @param dto
     * @return
     */
    @GetMapping("/page")
    public ApiResult<IPage<OrderEntity>> page(OrderPageQueryDTO dto) {
        return success(orderService.pageQuery(getPage(), dto));
    }

    /**
     * 明细查询
     *
     * @param id
     * @return
     */
    @GetMapping("/detail/{id:\\d+}")
    public ApiResult<OrderDTO> detail(@PathVariable Long id) {
        return success(orderService.detail(id));
    }

}